*Program to aggregate naics sectors;
%macro naics2dig;

naics2dig=floor(naics/10000);
*Natural Resources and Mining;
if naics2dig=11 or naics2dig=21 then naicssctr=1;
*Construction;
else if naics2dig=23 then naicssctr=2;
*Manufacturing;
else if 31<=naics2dig<=33 then naicssctr=3;
*Service-Providing;
else if naics2dig=22 or naics2dig=42 or naics2dig=44 or naics2dig=45 or naics2dig=48 or naics2dig=49 or naics2dig=22 then naicssctr=4;
*Info;
else if naics2dig=51 then naicssctr=5;
*FIRE;
else if naics2dig=52 or naics2dig=53 then naicssctr=6;
*Professional and Bus Services;
else if 54<=naics2dig<=56 then naicssctr=7;
*Ed and health services;
else if 61<=naics2dig<=62 then naicssctr=8;
*Leusire and Hosp;
else if 71<=naics2dig<=72 then naicssctr=9;
*Other services;
else if naics2dig=81 then naicssctr=10;

if naics2dig=92 or naics2dig=99 then delete;
%mend;

